<!--- START 以上内容不需更改，保证该TPL页内的标签匹配即可 --->
<div class="btn-toolbar" style="margin-bottom:2px;">
    <a href="/job/add" class="btn btn-primary"><i class="icon-plus"></i> 添加任务</a>
	<a data-toggle="collapse" data-target="#search" href="#" title="检索"><button class="btn btn-primary" style="margin-left:5px"><i class="icon-search"></i></button></a>
</div>
<div id="search" class="collapse out">
<form class="form_search" action="" method="GET" style="margin-bottom:0px">
	<div style="float:left;margin-right:5px">
		<label>机器</label>
		<select name="user_group" class="input-xlarge" id="DropDownTimezone">
		<?php $this->widget('application.widget.Group'); ?>
</select>

	</div>
	<div style="float:left;margin-right:5px">
		<label>查询所有用户请留空</label>
		<input type="text" name="user_name" value="" placeholder="输入登录名"> 
		<input type="hidden" name="search" value="1"> 
	</div>
	<div class="btn-toolbar" style="padding-top:25px;padding-bottom:0px;margin-bottom:0px">
		<button type="submit" class="btn btn-primary">检索</button>
	</div>
	<div style="clear:both;"></div>
</form>
</div>
    <div class="block">
        <a href="#page-stats" class="block-heading" data-toggle="collapse">任务列表</a>
        <div id="page-stats" class="block-body collapse in">
               <table class="table table-striped">
              <thead>
                <tr>
					<th style="width:20px">#</th>
					<th style="width:60px">任务名</th>
					<th style="width:40px">用户</th>
					<th style="width:40px">机器</th>
					<th style="width:80px">时间表达式</th>
					<th style="width:280px">脚本</th>
					<th style="width:40px">开始时间</th>
					<th style="width:40px">结束时间</th>
					<th style="width:40px">状态</th>
					<th style="width:40px">执行状态</th>
					<th style="width:100px">操作</th>
                </tr>
              </thead>
              <tbody>							   
             <?php foreach ($cronList as $val) { ?>
					<tr>
					<td><?php echo $val['id']; ?></td>
					<td><?php echo $val['name']; ?></td>
					<td><?php echo $val['uid']; ?></td>
					<td><?php echo $val['ip']; ?></td>
                    <td><?php echo $val['time']; ?></td>
                    <td><?php echo $val['cmd']; ?></td>
					<td><?php echo date("Y-m-d",$val['sTime']); ?></td>
					<td><?php echo date("Y-m-d",$val['eTime']); ?></td>
					<td><?php echo $val['status'] ==1? "激活":"关闭"?></td>
					<td><?php echo $val['running'] ==1? "执行中":"挂起"?></td>
					<td>
					<a href="/job/modify?id=<?php echo $val['id']; ?>" title= "修改" ><i class="icon-pencil"></i></a>&nbsp;
					<?php 	
						if ($val['status'] == 1){
					?>
					<a data-toggle="modal" href="#myModal"  title= "关闭" ><i class="icon-pause" href="/job/stop?page_no=<?php echo $page_no; ?>&id=<?php echo $val['id']; ?>"></i></a>
					<?php } ?>
					<?php if ($val['status'] == 0) {?>
					<a data-toggle="modal" href="#myModal" title= "开启" ><i class="icon-play" href="/job/open?page_no=<?php echo $page_no;  ?>&id=<?php echo $val['id']; ?>"></i></a>
                    <?php } ?>
					&nbsp;
						<a href="/job/history?cid=<?php echo $val['id']; ?>" title= "查看执行记录"><i class="icon-list-alt"></i></a>
                        <a data-toggle="modal" href="#myModal" title= "立即执行一次" ><i class="icon-play-circle" href="/job/AtOnce?page_no=<?php echo $page_no;  ?>&id=<?php echo $val['id']; ?>"></i></a>
					</td>
					</tr>
				<?php } ?>
			 </tbody>
            </table> 
				<!--- START 分页模板 --->
               <?php echo $page;?>					
			   <!--- END --->
        </div>
    </div>
<!---操作的确认层，相当于javascript:confirm函数--->
<script>
	$('.icon-pause').click(function () {
		var href = $(this).attr('href');
		bootbox.confirm('确定要这样做吗？', function (result) {
			if (result) {
				location.replace(href);
			}
		});
	})
	$('.icon-play').click(function () {
		var href = $(this).attr('href');
		bootbox.confirm('确定要这样做吗？', function (result) {
			if (result) {
				location.replace(href);
			}
		});
	})
	$('.icon-remove').click(function () {
		var href = $(this).attr('href');
		bootbox.confirm('确定要这样做吗？', function (result) {
			if (result) {
				location.replace(href);
			}
		});
	})

    $('.icon-play-circle').click(function () {
        var href = $(this).attr('href');
        bootbox.confirm('确定要这样做吗？', function (result) {
            if (result) {
                location.replace(href);
            }
        });
    })
</script>